VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "TestClassFixture"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit

Private mProjectName As String
Private mClassName As String
Private mClassFixture As ClassFixture
Private mSequenceLog As String

Private mFactory As New ProjectFactory


Public Sub testClassFixturesWithDummy()
given "Dummy"
'thenProjectNameMatches
thenClassNameMatches
thenNumberOfMethods 2
thenCallSequence "I.s.t1.t.s.t2.t.T"
thenElapsedTimeGt 0.000002
End Sub
Public Sub testClassFixturesWithDummy2()
given "Dummy2"
'thenProjectNameMatches
thenClassNameMatches
thenNumberOfMethods 3
thenCallSequence "I.s.s.s.T"
thenElapsedTimeGt 0.000002
End Sub

''
'' Logger
Public Sub Add(name As String)
If Len(mSequenceLog) = 0 Then
    mSequenceLog = name
Else
    mSequenceLog = mSequenceLog + "." + name
End If
End Sub
Private Sub clear()
mSequenceLog = ""
End Sub
''
''

Private Sub given(Class As String)
Dim project As String
Dim fullName As String
project = "prjTestVBUnit"
mClassName = Class
fullName = project & "." & Class
Set mClassFixture = mFactory.newClassFixture(classInfoFromName(CreateObject(fullName), Class))
End Sub

Private Sub thenClassNameMatches()
assert.equals mClassFixture.name, mClassName
End Sub

Private Sub thenNumberOfMethods(num As Integer)
assert.equals mClassFixture.numOfMethods, num, "Number of methods is" + Str(num)
End Sub
Private Sub thenCallSequence(sequence As String)
clear
mClassFixture.forward New MockNotifier
assert.equals mSequenceLog, sequence
End Sub
Private Sub thenElapsedTimeGt(value As Double)
assert.isTrue mClassFixture.elapsedTime > value, "Time is greater than" + Str(value)
End Sub

''
''

'Helper method to get CoClassInfo from instance
Private Function classInfoFromName(DummyObject As Object, Class As String) As CoClassInfo
Dim interface As InterfaceInfo
Set interface = InterfaceInfoFromObject(DummyObject)


Dim c As CoClassInfo
For Each c In interface.parent.CoClasses
    If c.name = Class Then
        Set classInfoFromName = c
        Exit Function
    End If
Next
End Function
'



'OPTIONAL METHODS
Public Sub setup()
Set dLogger = Me
mProjectName = "prjTestVBUnit"
End Sub
Public Sub teardown()
Set dLogger = Nothing
End Sub
Public Function NumOfAsserts() As Long
NumOfAsserts = 8
End Function

